function yld = yldoddl(sd,md,lcd,rv,price,cpn,per,basis)
%YLDODDL Yield with odd last period. Returns the yield of a security with
%   odd last period.
%
%   YLD = YLDODDL(SD,MD,LCD,RV,PRICE,CPN)
%   YLD = YLDODDL(SD,MD,LCD,RV,PRICE,CPN,PER)
%   YLD = YLDODDL(SD,MD,LCD,RV,PRICE,CPN,PER,BASIS)
%
%   Enter dates as serial date numbers or date strings.
%
%   Inputs:
%       SD      -  Settlement date
%       MD      -  Maturity date
%       LCD     -  Last coupon date
%       RV      -  Par value
%       PRICE   -  Price
%       CPN     -  Coupon rate
%
%  Optional Inputs:
%       PER     - the number of coupon periods per year
%                  1 - annual
%                  2 - semi-annual (default)
%                  3 - three times per year
%                  4 - quarterly
%                  6 - bi-monthly
%                 12 - monthly
%
%       BASIS   -  the day-count basis:
%                  0 = actual/actual (default)
%                  1 = 30/360 SIA
%                  2 = actual/360
%                  3 = actual/365
%                  4 = 30/360 PSA
%                  5 = 30/360 ISDA
%                  6 = 30E/360
%                  7 = actual/365 Japanese
%                  8 - actual/actual ISMA
%                  9 - actual/360 ISMA
%                 10 - actual/365 ISMA
%                 11 - 30/360 ISMA
%                 12 - actual/365 ISDA
%
%   Using the following data,
%
%      SD = '02/07/1993'
%      MD = '06/15/1993'
%      LCD = '10/15/1992'
%      RV = 100
%      PRICE = 99.878
%      CPN = 0.0375
%      PER = 2
%      BASIS = 1
%
%   yld = yldoddl(sd,md,lcd,rv,price,cpn,per,basis)
%
%   returns yld = 0.0405 or 4.05%.
%
%   See also YLDODDF, YLDBOND, YLDODDFL, PRODDL.
%
%   Reference: Mayle, Standard Securities Calculation Methods, Volumes
%              I-II, 3rd edition.  Formulas 10, 12, 14, 15.

% Copyright 1995-2006 The MathWorks, Inc.
% $Revision: 1.8.2.8 $   $Date: 2007/11/07 18:30:17 $

if nargin < 8
    basis = 0;
end

if nargin < 7
    per = 2;
end

if nargin < 6
    error('finance:yldoddl:tooFewInputs',...
        'Missing one of SD, MD, LCD, RV, PRICE, and CPN.')
end

if any(any(ischar(sd) | ischar(md) | ischar(lcd)))
    sd = datenum(sd);
    md = datenum(md);
    lcd = datenum(lcd);
end

if length(sd) == 1
    sd = sd*ones(size(md));
end

if length(md) == 1
    md = md*ones(size(sd));
end

if length(lcd) == 1
    lcd = lcd*ones(size(sd));
end

if length(rv) == 1
    rv = rv*ones(size(sd));
end

if length(price) == 1
    price = price*ones(size(sd));
end

if length(cpn) == 1
    cpn = cpn*ones(size(sd));
end

if length(per) == 1
    per = per*ones(size(sd));
end

if length(basis) == 1
    basis = basis*ones(size(sd));
end

if any(~isvalidbasis(basis))
    error('finance:yldoddl:invalidBasis',...
        'Invalid day count basis specified.');
end

if checksiz([size(sd);size(md);size(lcd);size(rv);size(price);size(cpn);...
        size(per);size(basis)],mfilename)
    return
end

yld = zeros(size(sd));
for i = 1:length(sd(:))
    if checkrng(str2mat('lcd','cpn','per'),...
            [lcd(i),cpn(i),per(i)],[-inf 0 0],...
            [md(i) inf inf],str2mat('sd','0','0'),...
            str2mat('md','inf','inf'),['l';'e';'l'],...
            ['e';'l';'l'],mfilename)
        return
    end
    if checktyp('per',per(i),'int',mfilename);return;end
end                  
% End for loop

yld  =  bndyield(price,cpn,sd,md,per,basis,[],[],[],lcd,[],rv);

% [EOF]
